package com.cqndt.disaster.device.util;

import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.math.BigDecimal;
import com.cqndt.disaster.device.domain.TabDevice;
import com.cqndt.disaster.device.domain.TabDeviceType;

public class ExplainUtil {

	/**
	 * @return 深部位移
	 **/
	public static void paramSbwy(String sensorNo,List<Map<String,Object>> results,
			Map<String,Object> map,TabDevice tabDevice,List<TabDeviceType> tabDeviceType,
							String... name) {
		if (results.size() <= 0) {
			return;
		}
		BigDecimal maxData = null;
		BigDecimal minData = null;
		for (int i = 0; i < name.length; i++) {
			List<Map<String, Object>> mapList = new ArrayList<>();
			for (Map<String, Object> mapResult : results) {
				Object time = mapResult.get("time");
				if (mapResult.get("param" + (i + 1)) != null && mapResult.get("param" + (i + 1)) != "") {
					BigDecimal initValue = BigDecimal.ZERO;
					List<Object> list1 = new ArrayList<>();
					for (int p = 0; p < 10; p++) {
						BigDecimal value = new BigDecimal(mapResult.get("param" + (p + 1)).toString())
								.subtract(initValue);
						list1.add(value);
					}
					Map<String, Object> map1 = new HashMap<>();
					map1.put("name", time);
					map1.put("value", list1);
					mapList.add(map1);
				}
			}
			if (mapList.size() > 0) {
				map.put("maxData", maxData);
				map.put("minData", minData);
				map.put(name[i], mapList);
				List<Map<String, Object>> list1 = new ArrayList<>();
				for (TabDeviceType tabDeviceType1 : tabDeviceType) {
					if (tabDeviceType1 != null) {
						Map<String, Object> map1 = new HashMap<>();
						map1.put("scale", tabDeviceType1.getScale() == null ? 0 : tabDeviceType1.getScale());
						map1.put("type", tabDeviceType1.getType() == null ? 0 : tabDeviceType1.getType());
						list1.add(map1);
					}
				}
				map.put("scale", list1);
			}
		}
	}

}